/*
 * File: NVM.c
 *
 * Code generated for Simulink model 'NVM'.
 *
 * Model version                  : 3.288
 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
 * C/C++ source code generated on : Thu Jan  5 16:57:51 2023
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: NXP->Cortex-M4
 * Code generation objective: MISRA C:2012 guidelines
 * Validation result: Not run
 */

#include "NVM.h"
#include "NVM_private.h"
#include "RTE.h"

/* Named constants for Chart: '<S5>/ToTalAhUpData' */
#define IN_Init                        ((uint8_T)1U)
#define IN_Work                        ((uint8_T)2U)

/* Block signals (default storage) */
B_NVM_T NVM_B;

/* Block states (default storage) */
DW_NVM_T NVM_DW;

/* Real-time model */
static RT_MODEL_NVM_T NVM_M_;
RT_MODEL_NVM_T *const NVM_M = &NVM_M_;

/* Exported data definition */

/* Definition for custom storage class: ExportToFile */
real32_T nvm_ah_Chg = 0.0F;            /* '<S5>/Product1' */
real32_T nvm_ah_Dsg = 0.0F;            /* '<S5>/Product' */
uint32_T nvm_ah_TatolAllChg = 0U;      /* '<S5>/ToTalAhUpData' */
uint32_T nvm_ah_TatolBack = 0U;        /* '<S5>/ToTalAhUpData' */
uint32_T nvm_ah_TatolChg = 0U;         /* '<S5>/ToTalAhUpData' */
uint32_T nvm_ah_TatolDsg = 0U;         /* '<S5>/ToTalAhUpData' */
uint32_T nvm_ah_sigDsgCap = 0U;        /* '<S5>/DataDeal' */
uint32_T nvm_kw_TatolAllChg = 0U;      /* '<S5>/ToTalAhUpData' */
uint32_T nvm_kw_TatolBack = 0U;        /* '<S5>/ToTalAhUpData' */
uint32_T nvm_kw_TatolDsg = 0U;         /* '<S5>/ToTalAhUpData' */
uint32_T nvm_kw_TotalChg = 0U;         /* '<S5>/ToTalAhUpData' */
uint32_T nvm_min_batLife = 0U;         /* '<S5>/DataDeal' */
uint32_T nvm_min_noChgTime = 0U;       /* '<S5>/DataDeal' */
uint32_T nvm_min_sleepTime = 0U;       /* '<S5>/DataDeal' */
RTC_TIME_STRUCT nvm_stu_RTCTag =
{
    0U,
    0U,
    0U,
    0U,
    0U,
    0U,
    0U,
    0U
};                                     /* '<S7>/Bus Creator' */

RTC_TIME_STRUCT nvm_stu_ReadRTCTime =
{
    0U,
    0U,
    0U,
    0U,
    0U,
    0U,
    0U,
    0U
};                                     /* '<S6>/Hex2Bcd' */

/* Forward declaration for local functions */
static void inner_default_Work(const real32_T *Product2, const real32_T
    *Product3);
static uint8_T BCD2HEX(uint8_T Data_BCD);

/* Function for Chart: '<S5>/ToTalAhUpData' */
static void inner_default_Work(const real32_T *Product2, const real32_T
    *Product3)
{
    real32_T tmp;
    tmp = nvm_ah_Dsg - NVM_DW.LastHisDsgAh;
    if (tmp >= 1.0F)
    {
        NVM_DW.CpCalcnDchg += tmp;
        NVM_B.nvm_ah_TatolDsg_l = (uint32_T)NVM_DW.CpCalcnDchg;
        NVM_DW.LastHisDsgAh = nvm_ah_Dsg;
    }

    tmp = nvm_ah_Chg - NVM_DW.LastHisChgAh;
    if (tmp >= 1.0F)
    {
        NVM_DW.CpCalcnAllChrg = (uint32_T)(tmp + (real32_T)NVM_DW.CpCalcnAllChrg);
        NVM_B.nvm_ah_TatolAllChg_e = NVM_DW.CpCalcnAllChrg;
        NVM_DW.LastHisChgAh = nvm_ah_Chg;
    }

    if (NVM_B.Divide4 - NVM_DW.LastDisAhEny >= 1U)
    {
        NVM_DW.TatolDhgEny = (NVM_DW.TatolDhgEny + NVM_B.Divide4) -
            NVM_DW.LastDisAhEny;
        NVM_B.nvm_kw_TatolDsg_f = NVM_DW.TatolDhgEny;
        NVM_DW.LastDisAhEny = NVM_B.Divide4;
    }

    if (NVM_B.Divide4_b - NVM_DW.LastChgAhEny >= 1U)
    {
        NVM_DW.TatolAllChgEny = (NVM_DW.TatolAllChgEny + NVM_B.Divide4_b) -
            NVM_DW.LastChgAhEny;
        NVM_B.nvm_kw_TatolAllChg_g = NVM_DW.TatolAllChgEny;
        NVM_DW.LastChgAhEny = NVM_B.Divide4_b;
    }

    tmp = *Product2 - NVM_DW.LastCpCalcnDCChg;
    if (tmp >= 1.0F)
    {
        NVM_DW.CpCalcnChg = (uint32_T)(tmp + (real32_T)NVM_DW.CpCalcnChg);
        NVM_B.nvm_ah_TotalChg = NVM_DW.CpCalcnChg;
        NVM_DW.LastCpCalcnDCChg = *Product2;
    }

    tmp = *Product3 - NVM_DW.LastCpCalcnBack;
    if (tmp >= 1.0F)
    {
        NVM_DW.CpCalcnBack += tmp;
        NVM_B.nvm_ah_TatolBack_m = (uint32_T)NVM_DW.CpCalcnBack;
        NVM_DW.LastCpCalcnBack = *Product3;
    }

    if (NVM_B.Divide4_f - NVM_DW.LastDCChgEny >= 1U)
    {
        NVM_DW.ChgEny = (NVM_DW.ChgEny + NVM_B.Divide4_f) - NVM_DW.LastDCChgEny;
        NVM_B.nvm_kw_TotalChg_b = NVM_DW.ChgEny;
        NVM_DW.LastDCChgEny = NVM_B.Divide4_f;
    }

    if (NVM_B.Divide4_l - NVM_DW.LastBackEny >= 1U)
    {
        NVM_DW.BackEny = (NVM_DW.BackEny + NVM_B.Divide4_l) - NVM_DW.LastBackEny;
        NVM_B.nvm_kw_TatolBack_l = NVM_DW.BackEny;
        NVM_DW.LastBackEny = NVM_B.Divide4_l;
    }
}

/* Function for Chart: '<S6>/Hex2Bcd' */
static uint8_T BCD2HEX(uint8_T Data_BCD)
{
    return (uint8_T)((int32_T)((uint32_T)Data_BCD >> 4) * 10 + Data_BCD % 16);
}

/* Model step function */
void TASK_Rte_NvmRead(void)
{
    uint32_T FunctionCaller1[11];

    /*
     * Block description for '<S7>/Function Caller':
     *  includes.h
     *
     * Block description for '<S7>/Function Caller':
     *  includes.h
     */
    EEPROM_vReadBytes(Pccfg_NvmDataLen, NVM_B.FunctionCaller_l);
    nvm_stu_RTCTag.second = (uint8_T)NVM_B.FunctionCaller_l[8];
    nvm_stu_RTCTag.minute = (uint8_T)NVM_B.FunctionCaller_l[9];
    nvm_stu_RTCTag.hour = (uint8_T)NVM_B.FunctionCaller_l[10];
    nvm_stu_RTCTag.day = (uint8_T)NVM_B.FunctionCaller_l[11];
    nvm_stu_RTCTag.week = (uint8_T)NVM_B.FunctionCaller_l[12];
    nvm_stu_RTCTag.month = (uint8_T)NVM_B.FunctionCaller_l[13];
    nvm_stu_RTCTag.year = (uint8_T)NVM_B.FunctionCaller_l[14];
    nvm_stu_RTCTag.crc8 = (uint8_T)NVM_B.FunctionCaller_l[15];

    /*
     * Block description for '<S7>/Function Caller1':
     *  includes.h
     *
     * Block description for '<S7>/Function Caller1':
     *  includes.h
     */
    EEPROM_ReadInitEEP(FunctionCaller1);
    if (FunctionCaller1[0] != 170U)
    {
        NVM_B.nvm_arr_RTCStartTag[0] = 170U;
        NVM_B.nvm_arr_RTCStartTag[1] = nvm_stu_RTCTag.second;
        NVM_B.nvm_arr_RTCStartTag[2] = nvm_stu_RTCTag.minute;
        NVM_B.nvm_arr_RTCStartTag[3] = nvm_stu_RTCTag.hour;
        NVM_B.nvm_arr_RTCStartTag[4] = nvm_stu_RTCTag.day;
        NVM_B.nvm_arr_RTCStartTag[5] = nvm_stu_RTCTag.week;
        NVM_B.nvm_arr_RTCStartTag[6] = nvm_stu_RTCTag.month;
        NVM_B.nvm_arr_RTCStartTag[7] = nvm_stu_RTCTag.year;
        NVM_B.nvm_arr_RTCStartTag[8] = 0U;
    }
    else
    {
        NVM_B.nvm_arr_RTCStartTag[0] = FunctionCaller1[0];
        NVM_B.nvm_arr_RTCStartTag[1] = FunctionCaller1[1];
        NVM_B.nvm_arr_RTCStartTag[2] = FunctionCaller1[2];
        NVM_B.nvm_arr_RTCStartTag[3] = FunctionCaller1[3];
        NVM_B.nvm_arr_RTCStartTag[4] = FunctionCaller1[4];
        NVM_B.nvm_arr_RTCStartTag[5] = FunctionCaller1[5];
        NVM_B.nvm_arr_RTCStartTag[6] = FunctionCaller1[6];
        NVM_B.nvm_arr_RTCStartTag[7] = FunctionCaller1[7];
        NVM_B.nvm_arr_RTCStartTag[8] = FunctionCaller1[8];
        NVM_B.eep_min_noChgTime = FunctionCaller1[9];
        NVM_B.eep_ah_sigDsgCap = FunctionCaller1[10];
    }
}

/* Model step function */
void TASK_10ms_AhCal(void)
{
    real32_T Product2;
    real32_T Product3;
    uint32_T ChgInteg_e;
    uint32_T DsgInteg_k;
    int16_T Saturation1;
    uint16_T Product30;
    Saturation1 = (int16_T)((int16_T)(Rte_ma_BatCurr_GetVal() / 1000U) - 1000);
    if (Saturation1 > 1000)
    {
        Saturation1 = 1000;
    }
    else
    {
        if (Saturation1 < -1000)
        {
            Saturation1 = -1000;
        }
    }

    Product30 = (uint16_T)((Rte_mv_PackVolt_GetVal() + 500U) / 1000U);
    if ((Saturation1 <= -1) && (vewm_enum_workingMode == ((uint8_T)
            Pdcfg_WmDsging)))
    {
        ChgInteg_e = (int16_T)-Saturation1 * 10 + NVM_DW.ChgIntegOld_a;
        DsgInteg_k = (int16_T)-Saturation1 * Product30 / 100U +
            NVM_DW.DsgIntegOld_e;
        NVM_B.ChgAhMs_n = (real32_T)ChgInteg_e / 3600.0F;
        NVM_B.Divide4_l = (int32_T)(DsgInteg_k / 3600U) * 10 / 1000U;
        NVM_DW.ChgIntegOld_a = ChgInteg_e;
        NVM_DW.DsgIntegOld_e = DsgInteg_k;
    }

    if (Saturation1 <= -1)
    {
        ChgInteg_e = (int16_T)-Saturation1 * 10 + NVM_DW.ChgIntegOld_e;
        DsgInteg_k = (int16_T)-Saturation1 * Product30 / 100U +
            NVM_DW.DsgIntegOld_h;
        NVM_B.ChgAhMs_i = (real32_T)ChgInteg_e / 3600.0F;
        NVM_B.Divide4_b = (int32_T)(DsgInteg_k / 3600U) * 10 / 1000U;
        NVM_DW.ChgIntegOld_e = ChgInteg_e;
        NVM_DW.DsgIntegOld_h = DsgInteg_k;
    }

    if ((Saturation1 <= -1) && ((vewm_enum_workingMode == ((uint8_T)
            Pdcfg_WmSChging)) || (vewm_enum_workingMode == ((uint8_T)
            Pdcfg_WmQChging))))
    {
        ChgInteg_e = (int16_T)-Saturation1 * 10 + NVM_DW.ChgIntegOld;
        DsgInteg_k = (int16_T)-Saturation1 * Product30 / 100U +
            NVM_DW.DsgIntegOld_c;
        NVM_B.ChgAhMs = (real32_T)ChgInteg_e / 3600.0F;
        NVM_B.Divide4_f = (int32_T)(DsgInteg_k / 3600U) * 10 / 1000U;
        NVM_DW.ChgIntegOld = ChgInteg_e;
        NVM_DW.DsgIntegOld_c = DsgInteg_k;
    }

    if (Saturation1 >= 1)
    {
        ChgInteg_e = Saturation1 * 10 + NVM_DW.DsgIntegOld;
        DsgInteg_k = Saturation1 * Product30 / 100U + NVM_DW.DsgIntegOld_f;
        NVM_B.DisAhMs_k = (real32_T)ChgInteg_e / 3600.0F;
        NVM_B.Divide4 = (int32_T)(DsgInteg_k / 3600U) * 10 / 1000U;
        NVM_DW.DsgIntegOld = ChgInteg_e;
        NVM_DW.DsgIntegOld_f = DsgInteg_k;
    }

    nvm_ah_Dsg = (real32_T)(NVM_B.DisAhMs_k * 0.01);
    nvm_ah_Chg = (real32_T)(NVM_B.ChgAhMs_i * 0.01);
    if (NVM_DW.AhCntr >= 500)
    {
        if ((NVM_B.nvm_arr_RTCStartTag[0] == 170U) && (NVM_DW.firstflg == 0))
        {
            NVM_DW.histroyTime = (((((nvm_stu_ReadRTCTime.year - (int32_T)
                NVM_B.nvm_arr_RTCStartTag[7]) * 365 * 24 * 60 +
                (nvm_stu_ReadRTCTime.month - (int32_T)NVM_B.nvm_arr_RTCStartTag
                 [6]) * 30 * 24 * 60) + (nvm_stu_ReadRTCTime.day - (int32_T)
                NVM_B.nvm_arr_RTCStartTag[4]) * 24 * 60) +
                                   (nvm_stu_ReadRTCTime.hour - (int32_T)
                                    NVM_B.nvm_arr_RTCStartTag[3]) * 60) +
                                  nvm_stu_ReadRTCTime.minute) - (int32_T)
                NVM_B.nvm_arr_RTCStartTag[2];
            if ((uint8_T)((((((nvm_stu_RTCTag.second + nvm_stu_RTCTag.minute) +
                              nvm_stu_RTCTag.hour) + nvm_stu_RTCTag.day) +
                            nvm_stu_RTCTag.week) + nvm_stu_RTCTag.month) +
                          nvm_stu_RTCTag.year) != nvm_stu_RTCTag.crc8)
            {
                NVM_B.nvm_min_sleepTime_k = 0U;
            }
            else
            {
                NVM_B.nvm_min_sleepTime_k = (uint32_T)
                    ((((((nvm_stu_ReadRTCTime.year - nvm_stu_RTCTag.year) * 365 *
                         24 * 60 + (nvm_stu_ReadRTCTime.month -
                                    nvm_stu_RTCTag.month) * 30 * 24 * 60) +
                        (nvm_stu_ReadRTCTime.day - nvm_stu_RTCTag.day) * 24 * 60)
                       + (nvm_stu_ReadRTCTime.hour - nvm_stu_RTCTag.hour) * 60)
                      + nvm_stu_ReadRTCTime.minute) - nvm_stu_RTCTag.minute);
            }

            NVM_DW.firstflg = 1U;
            NVM_DW.startNoChgTime = NVM_B.eep_min_noChgTime +
                NVM_B.nvm_min_sleepTime_k;
            NVM_DW.startSigDsgCap = NVM_B.eep_ah_sigDsgCap;
            NVM_B.nvm_ah_sigDsgCap_l = NVM_DW.startSigDsgCap;
        }

        if (NVM_DW.histroyTime >= 0)
        {
            NVM_B.batLife = rte_ms_sysRunTime_GetVal() / 1000U / 60U +
                NVM_DW.histroyTime;
        }
        else
        {
            NVM_B.batLife = 0U;
        }

        if (vewm_enum_SlowChgSts == 2)
        {
            NVM_DW.startNoChgTime = 0U;

            /*  startSigDsgCap = 0;
               nvm_ah_sigDsgCap = 0; */
        }

        NVM_B.nvm_min_noChgTime_d = rte_ms_sysRunTime_GetVal() / 1000U / 60U +
            NVM_DW.startNoChgTime;

        /* nvm_ah_sigDsgCap = startSigDsgCap + uint32(DsgAh) - oldDsgAh; */
        if (Rte_enum_SChgCcSts_GetVal() == 1)
        {
            if (NVM_DW.fstflg == 0)
            {
                NVM_DW.fstflg = 1U;
                NVM_DW.startSigDsgCap = 0U;
                NVM_DW.oldChgAllAh = (uint32_T)nvm_ah_Chg;
            }

            NVM_B.nvm_ah_sigDsgCap_l = (NVM_DW.startSigDsgCap + (uint32_T)
                nvm_ah_Chg) - NVM_DW.oldChgAllAh;
        }
        else
        {
            NVM_DW.fstflg = 0U;
        }

        NVM_DW.AhCntr = 0U;
    }
    else
    {
        NVM_DW.AhCntr++;
    }

    Product2 = (real32_T)(NVM_B.ChgAhMs * 0.01);
    Product3 = (real32_T)(NVM_B.ChgAhMs_n * 0.01);
    if (NVM_DW.AhCntr_l < 100)
    {
        NVM_DW.AhCntr_l++;
    }
    else
    {
        if (NVM_DW.is_active_c2_NVM == 0U)
        {
            NVM_DW.is_active_c2_NVM = 1U;
            NVM_DW.is_c2_NVM = IN_Init;
            NVM_DW.LastHisDsgAh = 0.0F;
            NVM_DW.LastHisChgAh = 0.0F;
            NVM_DW.LastDisAhEny = 0U;
            NVM_DW.LastChgAhEny = 0U;
            NVM_B.nvm_ah_TatolDsg_l = NVM_B.FunctionCaller_l[0];
            NVM_B.nvm_ah_TatolAllChg_e = NVM_B.FunctionCaller_l[1];
            NVM_B.nvm_kw_TatolDsg_f = NVM_B.FunctionCaller_l[2];
            NVM_B.nvm_kw_TatolAllChg_g = NVM_B.FunctionCaller_l[3];
            NVM_B.nvm_ah_TotalChg = NVM_B.FunctionCaller_l[4];
            NVM_B.nvm_ah_TatolBack_m = NVM_B.FunctionCaller_l[5];
            NVM_B.nvm_kw_TatolBack_l = NVM_B.FunctionCaller_l[6];
            NVM_B.nvm_kw_TotalChg_b = NVM_B.FunctionCaller_l[7];
            NVM_DW.CpCalcnDchg = (real32_T)NVM_B.FunctionCaller_l[0];
            NVM_DW.CpCalcnAllChrg = NVM_B.FunctionCaller_l[1];
            NVM_DW.TatolDhgEny = NVM_B.FunctionCaller_l[2];
            NVM_DW.TatolAllChgEny = NVM_B.FunctionCaller_l[3];
            NVM_DW.CpCalcnChg = NVM_B.FunctionCaller_l[4];
            NVM_DW.CpCalcnBack = (real32_T)NVM_B.FunctionCaller_l[5];
            NVM_DW.ChgEny = NVM_B.FunctionCaller_l[7];
            NVM_DW.BackEny = NVM_B.FunctionCaller_l[6];
        }
        else if (NVM_DW.is_c2_NVM == 1)
        {
            NVM_DW.is_c2_NVM = IN_Work;
            inner_default_Work(&Product2, &Product3);
        }
        else
        {
            /* case IN_Work: */
            inner_default_Work(&Product2, &Product3);
        }

        NVM_DW.AhCntr_l = 0U;
    }

    nvm_ah_TatolAllChg = NVM_B.nvm_ah_TatolAllChg_e;
    nvm_ah_TatolBack = NVM_B.nvm_ah_TatolBack_m;
    nvm_ah_TatolDsg = NVM_B.nvm_ah_TatolDsg_l;
    nvm_ah_TatolChg = NVM_B.nvm_ah_TotalChg;
    nvm_ah_sigDsgCap = NVM_B.nvm_ah_sigDsgCap_l;
    nvm_kw_TatolAllChg = NVM_B.nvm_kw_TatolAllChg_g;
    nvm_kw_TatolBack = NVM_B.nvm_kw_TatolBack_l;
    nvm_kw_TatolDsg = NVM_B.nvm_kw_TatolDsg_f;
    nvm_kw_TotalChg = NVM_B.nvm_kw_TotalChg_b;
    nvm_min_batLife = NVM_B.batLife;
    nvm_min_noChgTime = NVM_B.nvm_min_noChgTime_d;
    nvm_min_sleepTime = NVM_B.nvm_min_sleepTime_k;
}

/* Model step function */
void TASK_Rte_NvmWrite(void)
{
    int32_T i;
    uint32_T TmpSignalConversionAtFunctionCa[16];
    uint32_T TmpSignalConversionAtFunction_g[11];

    /*
     * Block description for SignalConversion generated from '<S8>/Function Caller':
     *  includes.h
     *
     * Block description for SignalConversion generated from '<S8>/Function Caller':
     *  includes.h
     */
    TmpSignalConversionAtFunctionCa[0] = nvm_ah_TatolDsg;
    TmpSignalConversionAtFunctionCa[1] = nvm_ah_TatolAllChg;
    TmpSignalConversionAtFunctionCa[2] = nvm_kw_TatolDsg;
    TmpSignalConversionAtFunctionCa[3] = nvm_kw_TatolAllChg;
    TmpSignalConversionAtFunctionCa[4] = nvm_ah_TatolChg;
    TmpSignalConversionAtFunctionCa[5] = nvm_ah_TatolBack;
    TmpSignalConversionAtFunctionCa[6] = nvm_kw_TatolBack;
    TmpSignalConversionAtFunctionCa[7] = nvm_kw_TotalChg;
    TmpSignalConversionAtFunctionCa[8] = nvm_stu_ReadRTCTime.second;
    TmpSignalConversionAtFunctionCa[9] = nvm_stu_ReadRTCTime.minute;
    TmpSignalConversionAtFunctionCa[10] = nvm_stu_ReadRTCTime.hour;
    TmpSignalConversionAtFunctionCa[11] = nvm_stu_ReadRTCTime.day;
    TmpSignalConversionAtFunctionCa[12] = nvm_stu_ReadRTCTime.week;
    TmpSignalConversionAtFunctionCa[13] = nvm_stu_ReadRTCTime.month;
    TmpSignalConversionAtFunctionCa[14] = nvm_stu_ReadRTCTime.year;
    TmpSignalConversionAtFunctionCa[15] = nvm_stu_ReadRTCTime.crc8;

    /*
     * Block description for '<S8>/Function Caller':
     *  includes.h
     *
     * Block description for SignalConversion generated from '<S8>/Function Caller':
     *  includes.h
     */
    EEPROM_vWriteBytes(Pccfg_NvmDataLen, TmpSignalConversionAtFunctionCa);

    /*
     * Block description for SignalConversion generated from '<S8>/Function Caller2':
     *  includes.h
     *
     * Block description for SignalConversion generated from '<S8>/Function Caller2':
     *  includes.h
     */
    for (i = 0; i < 9; i++)
    {
        TmpSignalConversionAtFunction_g[i] = NVM_B.nvm_arr_RTCStartTag[i];
    }

    TmpSignalConversionAtFunction_g[9] = nvm_min_noChgTime;
    TmpSignalConversionAtFunction_g[10] = nvm_ah_sigDsgCap;

    /*
     * Block description for '<S8>/Function Caller2':
     *  includes.h
     *
     * Block description for SignalConversion generated from '<S8>/Function Caller2':
     *  includes.h
     */
    EEPROM_WriteInitEEP(TmpSignalConversionAtFunction_g);
}

/* Model step function */
void TASK_ReadRTC(void)
{
    uint8_T FunctionCaller[8];

    /*
     * Block description for '<S6>/Function Caller':
     *  includes.h
     *
     * Block description for '<S6>/Function Caller':
     *  includes.h
     */
    BSW_ReadRtcTime(FunctionCaller);
    nvm_stu_ReadRTCTime.second = BCD2HEX(FunctionCaller[0]);
    nvm_stu_ReadRTCTime.minute = BCD2HEX(FunctionCaller[1]);
    nvm_stu_ReadRTCTime.hour = BCD2HEX(FunctionCaller[2]);
    nvm_stu_ReadRTCTime.day = BCD2HEX(FunctionCaller[3]);
    nvm_stu_ReadRTCTime.week = BCD2HEX(FunctionCaller[4]);
    nvm_stu_ReadRTCTime.month = BCD2HEX(FunctionCaller[5]);
    nvm_stu_ReadRTCTime.year = BCD2HEX(FunctionCaller[6]);
    nvm_stu_ReadRTCTime.crc8 = (uint8_T)((((((nvm_stu_ReadRTCTime.second +
        nvm_stu_ReadRTCTime.minute) + nvm_stu_ReadRTCTime.hour) +
        nvm_stu_ReadRTCTime.day) + nvm_stu_ReadRTCTime.week) +
        nvm_stu_ReadRTCTime.month) + nvm_stu_ReadRTCTime.year);
}

/* Model initialize function */
void NVM_initialize(void)
{
    NVM_DW.AhCntr = 500U;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
